{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"kmg_CNN_model.ipynb","provenance":[],"collapsed_sections":[],"mount_file_id":"1LvzSIzQlGI12xSHj02QIqiYIaWLtI5yP","authorship_tag":"ABX9TyNBEKetvVmBcgga28ha0OFm"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","metadata":{"id":"ltlqDxySMLzk"},"source":["# CNN 모델\n","\n","우리의 목표: 수동 작업 대신 다양한 유형의 웨이퍼 맵 고장 패턴을 자동으로 식별하여 반도체 제작으로 웨이퍼 제조 공정의 수율을 개선할 수 있다.\n","\n","데이터 : WM-811K wafer map"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"_JV06N2-L5jy","executionInfo":{"status":"ok","timestamp":1621951913925,"user_tz":-540,"elapsed":2321,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"8b3a5a1b-718f-41be-ed2c-d0c917807a92"},"source":["# loading libraries\n","import numpy as np # linear algebra\n","import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n","import matplotlib.pyplot as plt\n","%matplotlib inline \n","\n","import tensorflow as tf\n","import keras\n","from keras import layers, Input, models\n","from keras.utils import to_categorical\n","from keras.wrappers.scikit_learn import KerasClassifier \n","from sklearn.model_selection import KFold \n","from sklearn.model_selection import cross_val_score\n","\n","from sklearn.model_selection import train_test_split\n","\n","import os\n","from os.path import join\n","path = \"/content/drive/MyDrive/graduation/archive\"\n","print(os.listdir(path))\n","import warnings\n","warnings.filterwarnings(\"ignore\")"],"execution_count":null,"outputs":[{"output_type":"stream","text":["['LSWMD.pkl']\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"aN_2NYbS52pW"},"source":["데이터 요약"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"5m3lPxvyRdD8","executionInfo":{"status":"ok","timestamp":1621952055872,"user_tz":-540,"elapsed":141949,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"ac966dc6-86a4-45da-a570-40a4d365d97e"},"source":["df=pd.read_pickle(\"/content/drive/MyDrive/graduation/archive/LSWMD.pkl\")\n","df.info()"],"execution_count":null,"outputs":[{"output_type":"stream","text":["<class 'pandas.core.frame.DataFrame'>\n","RangeIndex: 811457 entries, 0 to 811456\n","Data columns (total 6 columns):\n"," #   Column          Non-Null Count   Dtype  \n","---  ------          --------------   -----  \n"," 0   waferMap        811457 non-null  object \n"," 1   dieSize         811457 non-null  float64\n"," 2   lotName         811457 non-null  object \n"," 3   waferIndex      811457 non-null  float64\n"," 4   trianTestLabel  811457 non-null  object \n"," 5   failureType     811457 non-null  object \n","dtypes: float64(2), object(4)\n","memory usage: 37.1+ MB\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"t6pe1bKFlY9Z"},"source":["데이터 세트구성\n","\n","\n","811,457 세트\n","1.   웨이퍼 맵\n","2.   웨이퍼 다이 크기\n","3.   로트 이름\n","4.   웨이퍼 인덱스 \n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":197},"id":"GeKNXW5NRjD1","executionInfo":{"status":"ok","timestamp":1621952055874,"user_tz":-540,"elapsed":12,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"006e7645-c606-4b17-a7de-3fbe01c29fb6"},"source":["df.head()"],"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>waferMap</th>\n","      <th>dieSize</th>\n","      <th>lotName</th>\n","      <th>waferIndex</th>\n","      <th>trianTestLabel</th>\n","      <th>failureType</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>1683.0</td>\n","      <td>lot1</td>\n","      <td>1.0</td>\n","      <td>[[Training]]</td>\n","      <td>[[none]]</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>1683.0</td>\n","      <td>lot1</td>\n","      <td>2.0</td>\n","      <td>[[Training]]</td>\n","      <td>[[none]]</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>1683.0</td>\n","      <td>lot1</td>\n","      <td>3.0</td>\n","      <td>[[Training]]</td>\n","      <td>[[none]]</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>1683.0</td>\n","      <td>lot1</td>\n","      <td>4.0</td>\n","      <td>[[Training]]</td>\n","      <td>[[none]]</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>1683.0</td>\n","      <td>lot1</td>\n","      <td>5.0</td>\n","      <td>[[Training]]</td>\n","      <td>[[none]]</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["                                            waferMap  ...  failureType\n","0  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...     [[none]]\n","1  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...     [[none]]\n","2  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...     [[none]]\n","3  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...     [[none]]\n","4  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...     [[none]]\n","\n","[5 rows x 6 columns]"]},"metadata":{"tags":[]},"execution_count":4}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":197},"id":"cocUusgDRlMM","executionInfo":{"status":"ok","timestamp":1621952056247,"user_tz":-540,"elapsed":378,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"8f603be5-1ccc-427d-e3bd-36c32010f66c"},"source":["df.tail()"],"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>waferMap</th>\n","      <th>dieSize</th>\n","      <th>lotName</th>\n","      <th>waferIndex</th>\n","      <th>trianTestLabel</th>\n","      <th>failureType</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>811452</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1,...</td>\n","      <td>600.0</td>\n","      <td>lot47542</td>\n","      <td>23.0</td>\n","      <td>[[Test]]</td>\n","      <td>[[Edge-Ring]]</td>\n","    </tr>\n","    <tr>\n","      <th>811453</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 1,...</td>\n","      <td>600.0</td>\n","      <td>lot47542</td>\n","      <td>24.0</td>\n","      <td>[[Test]]</td>\n","      <td>[[Edge-Loc]]</td>\n","    </tr>\n","    <tr>\n","      <th>811454</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1,...</td>\n","      <td>600.0</td>\n","      <td>lot47542</td>\n","      <td>25.0</td>\n","      <td>[[Test]]</td>\n","      <td>[[Edge-Ring]]</td>\n","    </tr>\n","    <tr>\n","      <th>811455</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,...</td>\n","      <td>600.0</td>\n","      <td>lot47543</td>\n","      <td>1.0</td>\n","      <td>[]</td>\n","      <td>[]</td>\n","    </tr>\n","    <tr>\n","      <th>811456</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1,...</td>\n","      <td>600.0</td>\n","      <td>lot47543</td>\n","      <td>2.0</td>\n","      <td>[]</td>\n","      <td>[]</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["                                                 waferMap  ...    failureType\n","811452  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1,...  ...  [[Edge-Ring]]\n","811453  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 1,...  ...   [[Edge-Loc]]\n","811454  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1,...  ...  [[Edge-Ring]]\n","811455  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,...  ...             []\n","811456  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1,...  ...             []\n","\n","[5 rows x 6 columns]"]},"metadata":{"tags":[]},"execution_count":5}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":294},"id":"t7zi85HDR0t0","executionInfo":{"status":"ok","timestamp":1621952056513,"user_tz":-540,"elapsed":268,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"0d0abfa1-5a87-47e5-8103-a195662fb9c8"},"source":["import matplotlib.pyplot as plt\n","%matplotlib inline\n","\n","\n","uni_Index=np.unique(df.waferIndex, return_counts=True)\n","plt.bar(uni_Index[0],uni_Index[1], color='gold', align='center', alpha=0.5)\n","plt.title(\" wafer Index distribution\")\n","plt.xlabel(\"index #\")\n","plt.ylabel(\"frequency\")\n","plt.xlim(0,26)\n","plt.ylim(30000,34000)\n","plt.show()"],"execution_count":null,"outputs":[{"output_type":"display_data","data":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAZEAAAEWCAYAAACnlKo3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3dfZweZX3v8c+XEEiEYhD2aEiQoOQcCiih7AnR+rI0CgTbAkepQlsJCsYqVNvaVmmt4cFa0bZU5MGDEAyUNlCqJSIxphKFo5KwQBIJD2XlMREhEALGh2ji9/wx18rtZndzZ7Kzm2S/79drXpn5zTUz19zc3L+95rpmRraJiIioY5fhrkBEROy4kkQiIqK2JJGIiKgtSSQiImpLEomIiNqSRCIiorYkkdhhSRor6cuSnpf079tBfb4h6cwhOI4lHVTmPyfpbwdpv6+UtF7SqLI8qOcjaYGkmYO1v9g+7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N8Cttt8taRywVNJ/AecAd0q6HbgYeEt5ztEv2f4JMEXSpcAc4DBgT9uXNnqGES3SEokYXEttryo/+MuAScDBwCO2HypPjP2XlvLHAh8pLYpvAGOAV9r+MfAeYBFwie3vDXDM1wArgdcCywf5fCIGlJZIxODa0DK/iS3/PybgbbYf7GPda4Bngf363LC63PU2qkd63wG8CjhW0ldt/+XWVjyijrREIpr3ADBJ0qvL8qkt6xYCf9LSd3JE+fcA4ENUl8eOl3RU753aPh84E7gaOApYbvs1SSAxlJJEIhpm+6fALOArpWO99d0VFwCjgRWSVgIXtDy++y9sfx84A7hS0pg+dv9bVE9pnUrVGokYUnmKb0RE1JaWSERE1JYkEhERtSWJREREbUkiERFRW5JIRETUliQSERG1JYlERERt/x/KCN0QbFGIDAAAAABJRU5ErkJggg==\n","text/plain":["<Figure size 432x288 with 1 Axes>"]},"metadata":{"tags":[],"needs_background":"light"}}]},{"cell_type":"code","metadata":{"id":"Y2zS39YaSeeL"},"source":["df = df.drop(['waferIndex'], axis = 1)"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"RE4CN7Belhh2"},"source":["웨이퍼 맵 컬럼에서 많은 정보는 얻지 못하지만, 각 인스턴스의 다이 크기가 다르다는 것을 알 수 있다.\n","\n","웨이퍼 Map Dim 검사를 위해 \n","\n","'waferMap Dim\" 변수 생성."]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":197},"id":"pH6_TPddSlX7","executionInfo":{"status":"ok","timestamp":1621952059128,"user_tz":-540,"elapsed":2618,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"4e5927bf-505f-40d0-e54a-f75f8c39f659"},"source":["def find_dim(x):\n","    dim0=np.size(x,axis=0)\n","    dim1=np.size(x,axis=1)\n","    return dim0,dim1\n","df['waferMapDim']=df.waferMap.apply(find_dim)\n","df.sample(5)"],"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>waferMap</th>\n","      <th>dieSize</th>\n","      <th>lotName</th>\n","      <th>trianTestLabel</th>\n","      <th>failureType</th>\n","      <th>waferMapDim</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>208007</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>3532.0</td>\n","      <td>lot13233</td>\n","      <td>[]</td>\n","      <td>[]</td>\n","      <td>(64, 71)</td>\n","    </tr>\n","    <tr>\n","      <th>696724</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2,...</td>\n","      <td>516.0</td>\n","      <td>lot42892</td>\n","      <td>[[Training]]</td>\n","      <td>[[none]]</td>\n","      <td>(25, 27)</td>\n","    </tr>\n","    <tr>\n","      <th>217920</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>14116.0</td>\n","      <td>lot13802</td>\n","      <td>[]</td>\n","      <td>[]</td>\n","      <td>(212, 84)</td>\n","    </tr>\n","    <tr>\n","      <th>67123</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>12552.0</td>\n","      <td>lot5105</td>\n","      <td>[]</td>\n","      <td>[]</td>\n","      <td>(137, 116)</td>\n","    </tr>\n","    <tr>\n","      <th>377155</th>\n","      <td>[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...</td>\n","      <td>2126.0</td>\n","      <td>lot22475</td>\n","      <td>[[Training]]</td>\n","      <td>[[Edge-Ring]]</td>\n","      <td>(53, 52)</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["                                                 waferMap  ...  waferMapDim\n","208007  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...     (64, 71)\n","696724  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2,...  ...     (25, 27)\n","217920  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...    (212, 84)\n","67123   [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...   (137, 116)\n","377155  [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...  ...     (53, 52)\n","\n","[5 rows x 6 columns]"]},"metadata":{"tags":[]},"execution_count":8}]},{"cell_type":"markdown","metadata":{"id":"yVWec8ss6GHf"},"source":["웨이퍼 해상도(26, 26)\n","Footly Case 라벨로 웨이퍼 및 어레이 배열,\n","일부 웨이퍼 라벨은 null인데 생략함."]},{"cell_type":"code","metadata":{"id":"wkTaMMwFS9s1"},"source":["sub_df = df.loc[df['waferMapDim'] == (26, 26)]\n","sub_wafer = sub_df['waferMap'].values\n","\n","sw = np.ones((1, 26, 26))\n","label = list()\n","\n","for i in range(len(sub_df)):\n","    # skip null label\n","    if len(sub_df.iloc[i,:]['failureType']) == 0:\n","        continue\n","    sw = np.concatenate((sw, sub_df.iloc[i,:]['waferMap'].reshape(1, 26, 26)))\n","    label.append(sub_df.iloc[i,:]['failureType'][0][0])"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"hamQI518TA2A"},"source":["x = sw[1:]\n","y = np.array(label).reshape((-1,1))"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"fLa3MD4zTDFM","executionInfo":{"status":"ok","timestamp":1621952244039,"user_tz":-540,"elapsed":9,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"79612eb3-ffb3-4d20-c583-13e0fa60c50c"},"source":["# check dimension\n","print('x shape : {}, y shape : {}'.format(x.shape, y.shape))"],"execution_count":null,"outputs":[{"output_type":"stream","text":["x shape : (14366, 26, 26), y shape : (14366, 1)\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"vXxw-BMY-8zW"},"source":["plot 1st data for check."]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":282},"id":"O-1vZwHYTKfD","executionInfo":{"status":"ok","timestamp":1621952244040,"user_tz":-540,"elapsed":8,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"df0ac80d-e18e-4cf3-b3d1-39ec699e92b0"},"source":["# plot 1st data\n","plt.imshow(x[0])\n","plt.show()\n","\n","# check faulty case\n","print('Faulty case : {} '.format(y[0]))"],"execution_count":null,"outputs":[{"output_type":"display_data","data":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAP0AAAD4CAYAAAAn+OBPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAANOklEQVR4nO3dX6wcdRnG8eexlBIKJK1gU7D+o3hBRIs5KSQSgyEKclO8QXthakI8mkACDRcSvJAbE2IsxQujOUpjNQqagKEXJLU2JsQLKgdSaQGVSgr9R1tTkwLGAuX1Yqf2QLtn5uzMzs6e9/tJTnZ3/uy8Z3qezuz8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NfnXPap3TDBZLhQh6QDKEHkiH0QDKEHkiG0APJEHogGUIPJPM/iEjMlWURcEAAAAAASUVORK5CYII=\n","text/plain":["<Figure size 432x288 with 1 Axes>"]},"metadata":{"tags":[],"needs_background":"light"}},{"output_type":"stream","text":["Faulty case : ['none'] \n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"oAlnyoAo_EEe"},"source":["차원을 확장한 2D Convolutional Autoencoder 사용."]},{"cell_type":"code","metadata":{"id":"fEjjc-v3TMjc"},"source":["#add channel\n","x = x.reshape((-1, 26, 26, 1))"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"adv93Ttf_RdG"},"source":["불량타입목록 생성, 불량타입확인"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"3JXYPemFTONz","executionInfo":{"status":"ok","timestamp":1621952244468,"user_tz":-540,"elapsed":435,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"c49bfd61-a826-44cc-b255-d636444a2bac"},"source":["faulty_case = np.unique(y)\n","print('Faulty case list : {}'.format(faulty_case))"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Faulty case list : ['Center' 'Donut' 'Edge-Loc' 'Edge-Ring' 'Loc' 'Near-full' 'Random'\n"," 'Scratch' 'none']\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"0yrrNJRUTP7k","executionInfo":{"status":"ok","timestamp":1621952244469,"user_tz":-540,"elapsed":4,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"3c524465-c748-4d48-9a6c-7a0a05ac3cb6"},"source":["for f in faulty_case :\n","    print('{} : {}'.format(f, len(y[y==f])))"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Center : 90\n","Donut : 1\n","Edge-Loc : 296\n","Edge-Ring : 31\n","Loc : 297\n","Near-full : 16\n","Random : 74\n","Scratch : 72\n","none : 13489\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"1AYAXa2aAIo9"},"source":["#https://blog.naver.com/oys0608/222324158962\n","(*참조_범주형 데이터를 칼럼으로 대체 하는 One-hot-Encoding)\n","웨이퍼가아니면 0 정상이면 1 오류면 2  범주형 변수"]},{"cell_type":"code","metadata":{"id":"6P3r7JLBTRyE"},"source":["# One-hot-Encoding faulty categorical variable as channel\n","new_x = np.zeros((len(x), 26, 26, 3))\n","\n","for w in range(len(x)):\n","    for i in range(26):\n","        for j in range(26):\n","            new_x[w, i, j, int(x[w, i, j])] = 1"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"TKfqxWUrTT2E","executionInfo":{"status":"ok","timestamp":1621952251954,"user_tz":-540,"elapsed":12,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"f57a24e5-e75b-46ba-c722-6bb3023e7317"},"source":["#check new x dimension\n","new_x.shape"],"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["(14366, 26, 26, 3)"]},"metadata":{"tags":[]},"execution_count":17}]},{"cell_type":"markdown","metadata":{"id":"4KHFCfklTz98"},"source":["데이터 불균형 문제를 해결하기 위해 데이터 확대 필요.\n","웨이퍼 데이터는 이미지 데이터이므로 Convolutional Autoencoder 사용.\n","\n","\n","\n","\n"]},{"cell_type":"code","metadata":{"id":"3ejoKrqIT0c8"},"source":["# parameter\n","epoch=15\n","batch_size=1024"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"0V7S__i7T3UL"},"source":["# Encoder\n","input_shape = (26, 26, 3)\n","input_tensor = Input(input_shape)\n","encode = layers.Conv2D(64, (3,3), padding='same', activation='relu')(input_tensor)\n","\n","latent_vector = layers.MaxPool2D()(encode)\n","\n","# Decoder\n","decode_layer_1 = layers.Conv2DTranspose(64, (3,3), padding='same', activation='relu')\n","decode_layer_2 = layers.UpSampling2D()\n","output_tensor = layers.Conv2DTranspose(3, (3,3), padding='same', activation='sigmoid')\n","\n","# connect decoder layers\n","decode = decode_layer_1(latent_vector)\n","decode = decode_layer_2(decode)\n","\n","ae = models.Model(input_tensor, output_tensor(decode))\n","ae.compile(optimizer = 'Adam',\n","              loss = 'mse',\n","             )"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"R79JDhTqMKfk","executionInfo":{"status":"ok","timestamp":1621952252259,"user_tz":-540,"elapsed":3,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"e211218f-2cd4-453e-e862-9d30f7b40bfd"},"source":["ae.summary()"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Model: \"model\"\n","_________________________________________________________________\n","Layer (type)                 Output Shape              Param #   \n","=================================================================\n","input_1 (InputLayer)         [(None, 26, 26, 3)]       0         \n","_________________________________________________________________\n","conv2d (Conv2D)              (None, 26, 26, 64)        1792      \n","_________________________________________________________________\n","max_pooling2d (MaxPooling2D) (None, 13, 13, 64)        0         \n","_________________________________________________________________\n","conv2d_transpose (Conv2DTran (None, 13, 13, 64)        36928     \n","_________________________________________________________________\n","up_sampling2d (UpSampling2D) (None, 26, 26, 64)        0         \n","_________________________________________________________________\n","conv2d_transpose_1 (Conv2DTr (None, 26, 26, 3)         1731      \n","=================================================================\n","Total params: 40,451\n","Trainable params: 40,451\n","Non-trainable params: 0\n","_________________________________________________________________\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"qh55dZnYMNar","executionInfo":{"status":"ok","timestamp":1621952628946,"user_tz":-540,"elapsed":376688,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"6477bf08-3ed5-4ba9-c6c3-7ac6b75c102f"},"source":["# start train\n","ae.fit(new_x, new_x,\n","       batch_size=batch_size,\n","       epochs=epoch,\n","       verbose=2)"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Epoch 1/15\n","15/15 - 27s - loss: 0.1557\n","Epoch 2/15\n","15/15 - 25s - loss: 0.0931\n","Epoch 3/15\n","15/15 - 25s - loss: 0.0807\n","Epoch 4/15\n","15/15 - 26s - loss: 0.0705\n","Epoch 5/15\n","15/15 - 26s - loss: 0.0622\n","Epoch 6/15\n","15/15 - 25s - loss: 0.0553\n","Epoch 7/15\n","15/15 - 26s - loss: 0.0492\n","Epoch 8/15\n","15/15 - 27s - loss: 0.0434\n","Epoch 9/15\n","15/15 - 26s - loss: 0.0376\n","Epoch 10/15\n","15/15 - 26s - loss: 0.0327\n","Epoch 11/15\n","15/15 - 26s - loss: 0.0289\n","Epoch 12/15\n","15/15 - 25s - loss: 0.0259\n","Epoch 13/15\n","15/15 - 23s - loss: 0.0235\n","Epoch 14/15\n","15/15 - 21s - loss: 0.0215\n","Epoch 15/15\n","15/15 - 23s - loss: 0.0198\n"],"name":"stdout"},{"output_type":"execute_result","data":{"text/plain":["<tensorflow.python.keras.callbacks.History at 0x7f6ba5ea6950>"]},"metadata":{"tags":[]},"execution_count":21}]},{"cell_type":"markdown","metadata":{"id":"2k9eUYtOV7RS"},"source":["오토인코더 모델 레이어의 일부로 인코더 모델 제작"]},{"cell_type":"code","metadata":{"id":"KEpPho3XO-_8"},"source":["# Make encoder model with part of autoencoder model layers\n","encoder = models.Model(input_tensor, latent_vector)"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"TzUX_C-rV-Xq"},"source":["오토인코더 모델 레이어의 일부로 디코더 모델 제작"]},{"cell_type":"code","metadata":{"id":"ooLEocj_PAuT"},"source":["# Make decoder model with part of autoencoder model layers\n","decoder_input = Input((13, 13, 64))\n","decode = decode_layer_1(decoder_input)\n","decode = decode_layer_2(decode)\n","\n","decoder = models.Model(decoder_input, output_tensor(decode))"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"koLYtjK0WOGh"},"source":["오리지널 결함 웨이퍼 인코딩"]},{"cell_type":"code","metadata":{"id":"QDjh7yEHPB8L"},"source":["# Encode original faulty wafer\n","encoded_x = encoder.predict(new_x)"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"Y92o1FE1WRp6"},"source":["인코딩된 잠재적 결함 웨이퍼 벡터에 노이즈 추가"]},{"cell_type":"code","metadata":{"id":"YFzRB8YQPDEK"},"source":["# Add noise to encoded latent faulty wafers vector.\n","noised_encoded_x = encoded_x + np.random.normal(loc=0, scale=0.1, size = (len(encoded_x), 13, 13, 64))"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"MeAG3MiRWVyI"},"source":["원본 결함 웨이퍼 데이터 확인"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":282},"id":"N0Uvxc0LPEL5","executionInfo":{"status":"ok","timestamp":1621952641533,"user_tz":-540,"elapsed":7,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"04b9dba5-9e86-4176-9051-e4ee5e985792"},"source":["# check original faulty wafer data\n","plt.imshow(np.argmax(new_x[3], axis=2))"],"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["<matplotlib.image.AxesImage at 0x7f6ba8218910>"]},"metadata":{"tags":[]},"execution_count":26},{"output_type":"display_data","data":{"image/png":"iVBORw0KGg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zQivizpSknXFx9ZOy9639u62B5baRyGcTjBmBH/16XjOezYFvPGFfr9ktYueHxOsaxzImJ/cXtI0oPqM25ARxyc/8lzcXtozPUcp+o4DG070ZgR6uDxrDO2xbxxhf5xSefZ/pztUyRdK2nrmGrpy/aK4oKJbK+Q9A11e9yArZI2Ffc3SXpojLWcUBfHYeg3ZoQ6djwbG9siIsbyJ+kq9a7g/1vSD8dVR0mNn5f0VPH3TJfqlHSfeh/l3lPvmsh1kj4paVbS85L+KmlVB2v8naRdkp5WL1RrOnAsL1Xvo/vTknYWf1d18Hj2q/OkjindcIFkuJAHJEPogWQIPZAMoQeSIfRAMoQeSIbQA8n8D0ANwVRWl4r4AAAAAElFTkSuQmCC\n","text/plain":["<Figure size 432x288 with 1 Axes>"]},"metadata":{"tags":[],"needs_background":"light"}}]},{"cell_type":"markdown","metadata":{"id":"pHapAleyWZDJ"},"source":["신규 노이즈 결함 웨이퍼 데이터 확인"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":282},"id":"YgqTVc5aPQvT","executionInfo":{"status":"ok","timestamp":1621952650750,"user_tz":-540,"elapsed":9221,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"447d7f0e-0620-47ec-c6c1-66295fab6e7d"},"source":["# check new noised faulty wafer data\n","noised_gen_x = np.argmax(decoder.predict(noised_encoded_x), axis=3)\n","plt.imshow(noised_gen_x[3])"],"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["<matplotlib.image.AxesImage at 0x7f6ba985e390>"]},"metadata":{"tags":[]},"execution_count":27},{"output_type":"display_data","data":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAP0AAAD4CAYAAAAn+OBPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdG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1e3Z43YLukLcX9LZLum2Atp9TFeRiGzRmhjrVnY3NbRMRE/iRdrcEZ/H9K+s6k6iip8cOS/lr8PdGlOiXdrcFHuTc1OCfyNUkfkLRL0tOS/ihpTQdr/KWkvZIe1yBU6zrQlldo8NH9cUl7ir+rO9iew+o8rTZlGC6QDCfygGQIPZAMoQeSIfRAMoQeSIbQA8kQeiCZ/wJhYoq3of+WuAAAAABJRU5ErkJggg==\n","text/plain":["<Figure size 432x288 with 1 Axes>"]},"metadata":{"tags":[],"needs_background":"light"}}]},{"cell_type":"markdown","metadata":{"id":"UJxd9rLOZ_yg"},"source":["재구성된 오리지널 결함 웨이퍼 데이터 확인"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":282},"id":"d2OHogeVPU4C","executionInfo":{"status":"ok","timestamp":1621952661061,"user_tz":-540,"elapsed":10319,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"13a88ec3-358d-404b-a856-8c9dff9871c2"},"source":["# check reconstructed original faulty wafer data\n","gen_x = np.argmax(ae.predict(new_x), axis=3)\n","plt.imshow(gen_x[3])"],"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["<matplotlib.image.AxesImage at 0x7f6bab1d3e90>"]},"metadata":{"tags":[]},"execution_count":28},{"output_type":"display_data","data":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAP0AAAD4CAYAAAAn+OBPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAANIklEQVR4nO3dUawcZRnG8eexljYWSFrBpkAVRW6IxmpOConEaIiC3BRv0F6QmhCPJpKI4UKCF3JJjFC9MJiDEItR0EQJvSCWem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ntIgVOs60JaXa/DW/SlJu4ufqzvYnsPqPK02ZRgukAwn8oBkCD2QDKEHkiH0QDKEHkiG0APJEHogmf8B3DmdtiZrR2cAAAAASUVORK5CYII=\n","text/plain":["<Figure size 432x288 with 1 Axes>"]},"metadata":{"tags":[],"needs_background":"light"}}]},{"cell_type":"markdown","metadata":{"id":"VweQMayTgCCQ"},"source":["각 케이스마다 2000개의 샘플이 있는 데이터로, 모든 결함있는 사례에 대한 데이터를 위와 같은 방식으로 확대 할 것이다."]},{"cell_type":"code","metadata":{"id":"amkl4lmSgBuX"},"source":["# augment function define\n","def gen_data(wafer, label):\n","    # Encode input wafer\n","    encoded_x = encoder.predict(wafer)\n","    \n","    # dummy array for collecting noised wafer\n","    gen_x = np.zeros((1, 26, 26, 3))\n","    \n","    # Make wafer until total # of wafer to 2000\n","    for i in range((2000//len(wafer)) + 1):\n","        noised_encoded_x = encoded_x + np.random.normal(loc=0, scale=0.1, size = (len(encoded_x), 13, 13, 64)) \n","        noised_gen_x = decoder.predict(noised_encoded_x)\n","        gen_x = np.concatenate((gen_x, noised_gen_x), axis=0)\n","    # also make label vector with same length\n","    gen_y = np.full((len(gen_x), 1), label)\n","    \n","    # return date without 1st dummy data.\n","    return gen_x[1:], gen_y[1:]"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"mcGcNTB1gLP_"},"source":["# Augmentation for all faulty case.\n","for f in faulty_case : \n","    # skip none case\n","    if f == 'none' : \n","        continue\n","    \n","    gen_x, gen_y = gen_data(new_x[np.where(y==f)[0]], f)\n","    new_x = np.concatenate((new_x, gen_x), axis=0)\n","    y = np.concatenate((y, gen_y))"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ZpZIrUlwgOs-","executionInfo":{"status":"ok","timestamp":1621952762652,"user_tz":-540,"elapsed":20,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"24a74150-1723-4096-c96b-f5bb6fdb4b4d"},"source":["for f in faulty_case :\n","    print('{} : {}'.format(f, len(y[y==f])))"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Center : 2160\n","Donut : 2002\n","Edge-Loc : 2368\n","Edge-Ring : 2046\n","Loc : 2376\n","Near-full : 2032\n","Random : 2146\n","Scratch : 2088\n","none : 13489\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"XzngkQ90gr4X"},"source":["# choice index without replace.\n","none_idx = np.where(y=='none')[0][np.random.choice(len(np.where(y=='none')[0]), size=11000, replace=False)]"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"syN9e71FgtQv"},"source":["# delete choiced index data.\n","new_x = np.delete(new_x, none_idx, axis=0)\n","new_y = np.delete(y, none_idx, axis=0)"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"GLyxXVXWgu6O","executionInfo":{"status":"ok","timestamp":1621952762653,"user_tz":-540,"elapsed":15,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"d37d285b-6f2e-4401-d280-5224d0bf35cd"},"source":["print('After Delete \"none\" class new_x shape : {}, new_y shape : {}'.format(new_x.shape, new_y.shape))"],"execution_count":null,"outputs":[{"output_type":"stream","text":["After Delete \"none\" class new_x shape : (19707, 26, 26, 3), new_y shape : (19707, 1)\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"6rp23-Ipgxu4","executionInfo":{"status":"ok","timestamp":1621952762654,"user_tz":-540,"elapsed":14,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"d88ad0f0-c853-407d-bc70-443bcc012344"},"source":["for f in faulty_case :\n","    print('{} : {}'.format(f, len(new_y[new_y==f])))"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Center : 2160\n","Donut : 2002\n","Edge-Loc : 2368\n","Edge-Ring : 2046\n","Loc : 2376\n","Near-full : 2032\n","Random : 2146\n","Scratch : 2088\n","none : 2489\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"ZpISPzg7g1bW"},"source":["# make string label data to numerical data\n","for i, l in enumerate(faulty_case):\n","    new_y[new_y==l] = i\n","    \n","# one-hot-encoding\n","new_y = to_categorical(new_y)\n"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"jskygc-7g3EW"},"source":["# split data train, test\n","x_train, x_test, y_train, y_test = train_test_split(new_x, new_y,\n","                                                    test_size=0.33,\n","                                                    random_state=2019)"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"hZQKib3qg28V","executionInfo":{"status":"ok","timestamp":1621952763010,"user_tz":-540,"elapsed":3,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"98af0bb4-8462-444c-ae2a-38c924185882"},"source":["print('Train x : {}, y : {}'.format(x_train.shape, y_train.shape))\n","print('Test x: {}, y : {}'.format(x_test.shape, y_test.shape))\n"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Train x : (13203, 26, 26, 3), y : (13203, 9)\n","Test x: (6504, 26, 26, 3), y : (6504, 9)\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"QyNlyrWng8cl"},"source":["Simple 2D CNN Model\n","웨이퍼 데이터가 이미지 이기 때문에, CNN모델을 분류에 사용한다."]},{"cell_type":"markdown","metadata":{"id":"pRIc3CvbhHve"},"source":["모델 생성 함수를 정의하고, Sklearn교차 검증 을통해 모델을 검증 할것"]},{"cell_type":"code","metadata":{"id":"ddrykcTDhMzn"},"source":["def create_model():\n","    input_shape = (26, 26, 3)\n","    input_tensor = Input(input_shape)\n","\n","    conv_1 = layers.Conv2D(16, (3,3), activation='relu', padding='same')(input_tensor)\n","    conv_2 = layers.Conv2D(64, (3,3), activation='relu', padding='same')(conv_1)\n","    conv_3 = layers.Conv2D(128, (3,3), activation='relu', padding='same')(conv_2)\n","\n","    flat = layers.Flatten()(conv_3)\n","\n","    dense_1 = layers.Dense(512, activation='relu')(flat)\n","    dense_2 = layers.Dense(128, activation='relu')(dense_1)\n","    output_tensor = layers.Dense(9, activation='softmax')(dense_2)\n","\n","    model = models.Model(input_tensor, output_tensor)\n","    model.compile(optimizer='Adam',\n","                 loss='categorical_crossentropy',\n","                 metrics=['accuracy'])\n","\n","    return model\n"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"j9maY4UzhP4Y"},"source":["K Fold Cross검증을 사용하여 CNN을 검증\n","\n","K_Fold 는, K개의 fold를 만들어서 진행하는 교차검증이다.\n","\n","\n","사용이유 - 총 데이터 갯수가 적은 데이터 셋에 대하여 정확도를 향상 시킬 수 있음![image.png]()\n","\n","\n","![image.png]()"]},{"cell_type":"markdown","metadata":{"id":"kFfx-dj3proF"},"source":["k_fold vaclidation 원리 **참조**(https://nonmeyet.tistory.com/entry/KFold-Cross-Validation%EA%B5%90%EC%B0%A8%EA%B2%80%EC%A6%9D-%EC%A0%95%EC%9D%98-%EB%B0%8F-%EC%84%A4%EB%AA%85)"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"xQoJNKtmhWnJ","executionInfo":{"status":"ok","timestamp":1621954733817,"user_tz":-540,"elapsed":1970809,"user":{"displayName":"김민교","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Ggzz5q6oPD4Q_Rg1VraDwDNiro75vfgVYPTUUs0=s64","userId":"06703687637189135655"}},"outputId":"f2984782-1ee1-4185-c2bc-d1308cf99c2f"},"source":["# Make keras model to sklearn classifier.\n","model = KerasClassifier(build_fn=create_model, epochs=10, batch_size=1024, verbose=2) \n","# 3-Fold Crossvalidation\n","kfold = KFold(n_splits=3, shuffle=True, random_state=2019) \n","results = cross_val_score(model, x_train, y_train, cv=kfold)\n","# Check 3-fold model's mean accuracy\n","print('Simple CNN Cross validation score : {:.4f}'.format(np.mean(results)))"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Epoch 1/10\n","9/9 - 73s - loss: 2.4772 - accuracy: 0.3221\n","Epoch 2/10\n","9/9 - 72s - loss: 1.0138 - accuracy: 0.6442\n","Epoch 3/10\n","9/9 - 69s - loss: 0.6071 - accuracy: 0.7618\n","Epoch 4/10\n","9/9 - 70s - loss: 0.4489 - accuracy: 0.8643\n","Epoch 5/10\n","9/9 - 70s - loss: 0.2712 - accuracy: 0.9214\n","Epoch 6/10\n","9/9 - 65s - loss: 0.1612 - accuracy: 0.9517\n","Epoch 7/10\n","9/9 - 65s - loss: 0.1228 - accuracy: 0.9608\n","Epoch 8/10\n","9/9 - 62s - loss: 0.8245 - accuracy: 0.8317\n","Epoch 9/10\n","9/9 - 64s - loss: 0.2880 - accuracy: 0.9335\n","Epoch 10/10\n","9/9 - 63s - loss: 0.1415 - accuracy: 0.9589\n","5/5 - 9s - loss: 0.1189 - accuracy: 0.9591\n","Epoch 1/10\n","9/9 - 67s - loss: 2.6219 - accuracy: 0.2178\n","Epoch 2/10\n","9/9 - 64s - loss: 1.3125 - accuracy: 0.5489\n","Epoch 3/10\n","9/9 - 64s - loss: 1.0665 - accuracy: 0.6251\n","Epoch 4/10\n","9/9 - 63s - loss: 0.7184 - accuracy: 0.7581\n","Epoch 5/10\n","9/9 - 61s - loss: 0.4624 - accuracy: 0.8369\n","Epoch 6/10\n","9/9 - 62s - loss: 0.3161 - accuracy: 0.8945\n","Epoch 7/10\n","9/9 - 64s - loss: 0.2166 - accuracy: 0.9342\n","Epoch 8/10\n","9/9 - 64s - loss: 0.1536 - accuracy: 0.9529\n","Epoch 9/10\n","9/9 - 63s - loss: 0.1016 - accuracy: 0.9721\n","Epoch 10/10\n","9/9 - 62s - loss: 0.0649 - accuracy: 0.9833\n","5/5 - 8s - loss: 0.0722 - accuracy: 0.9777\n","Epoch 1/10\n","9/9 - 63s - loss: 2.1622 - accuracy: 0.3167\n","Epoch 2/10\n","9/9 - 62s - loss: 1.0125 - accuracy: 0.6609\n","Epoch 3/10\n","9/9 - 64s - loss: 0.5750 - accuracy: 0.7835\n","Epoch 4/10\n","9/9 - 64s - loss: 0.8607 - accuracy: 0.8516\n","Epoch 5/10\n","9/9 - 62s - loss: 0.4596 - accuracy: 0.8336\n","Epoch 6/10\n","9/9 - 64s - loss: 0.2551 - accuracy: 0.9229\n","Epoch 7/10\n","9/9 - 65s - loss: 0.1533 - accuracy: 0.9555\n","Epoch 8/10\n","9/9 - 64s - loss: 0.0944 - accuracy: 0.9705\n","Epoch 9/10\n","9/9 - 65s - loss: 0.0578 - accuracy: 0.9864\n","Epoch 10/10\n","9/9 - 68s - loss: 0.0360 - accuracy: 0.9911\n","5/5 - 9s - loss: 0.0762 - accuracy: 0.9748\n","Simple CNN Cross validation score : 0.9705\n"],"name":"stdout"}]}]}